package com.nick.order.config;


import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RoundRobinRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @ClassName: ApplicationConfig
 * @Descpriction: 全局配置
 * @author: zhangchao
 * @date: 2020/4/28 18:54
 * @version: 1.0
 */
@Configuration
public class ApplicationConfig {
    @Bean
    public IRule ribbonRule() {
        return new RoundRobinRule();
    }

    // 开启消息者端的负载均衡功能，默认是轮询策略
    @LoadBalanced
    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
